#!/usr/bin/ksh

###Script to perform write suspend & write resume on DB2 databases###
###This is useful when performing Clone/Snap/Snapshot operations###

DEBUG=no
[[ "$DEBUG" = yes ]] && set -x

SYNTAX() {
[[ "$DEBUG" = yes ]] && set -x
echo "$0 ( suspend | resume )"
echo
}


SUS() {
[[ "$DEBUG" = yes ]] && set -x

###You may need to update your logarchmeth depending on your backup software###
#db2 update db cfg for DB01 using logarchmeth2 off deferred;
#db2 update db cfg for DB01 using logarchmeth1 DISK:/db2_arch_logs deferred;
#db2 "update db cfg for DB01 using logarchopt1 ''" deferred;

for x in DB01 DB02
	do
	db2 connect to $x
	db2 set write suspend for database
	db2 terminate
done
}


RES() {
[[ "$DEBUG" = yes ]] && set -x
for x in DB01 DB02
	do
	db2 connect to $x
	db2 set write resume for database
	db2 terminate
done

###You may need to update your logarchmeth depending on your backup software###
#db2 "update db cfg for DB01 using logarchmeth1 VENDOR:/usr/lib/libnsrdb2.o" deferred;
#db2 "update db cfg for DB01 using LOGARCHOPT1  @/nsr/scripts/db2.log.cfg" deferred;
#db2 " update db cfg for DB01 using logarchmeth2 DISK:/db2_arch_logs" deferred;
}


case $1 in

	suspend)  	SUS ;;
	resume) 	RES ;;
	*) 		SYNTAX ;;
esac 

